package com.sicheng.lc.周赛.分类.哈西表or计数or滑动窗口or双指针;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/25 15:35
 */
public class 找出两数组的不同 {
    //https://leetcode.cn/problems/find-the-difference-of-two-arrays/
    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {
        int[] nums = new int[2001];
        for (int i : nums1) {
            nums[i + 1000]++;
        }
        ArrayList<Integer> list2 = new ArrayList<>();
        ArrayList<Integer> list1 = new ArrayList<>();
        for (int i : nums2) {
            if (nums[i + 1000] == 0) {
                nums[i + 1000] = -1;
                list2.add(i);
            } else if (nums[i + 1000] > 0) {
                nums[i + 1000] = -1;
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if (nums[i] > 0)
                list1.add(i - 1000);
        }
        ArrayList<List<Integer>> res = new ArrayList<>();
        res.add(list1);
        res.add(list2);
        return res;
    }

    public static void main(String[] args) {
        找出两数组的不同 solution = new 找出两数组的不同();
        int[] nums1 = {1, 2, 3, 3}, nums2 = {1, 1, 2, 2};
        List<List<Integer>> res = solution.findDifference(nums1, nums2);
        System.out.println(res);
    }
}
